package com.bw.study;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.LayoutInflater;

import com.bw.study.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {

    private ActivityMainBinding mainBinding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);
        //构建ActivityMainBinding对象
        mainBinding = ActivityMainBinding.inflate(LayoutInflater.from(this));
        //viewbinding关联到Activity中
        setContentView(mainBinding.getRoot());
        mainBinding.mainTv.setText("Hello ViewBinding");
    }
}